-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger post hook on Event Copy #12990
Conversation
(Standard links)
|
@mattwire there is a style warning. Could the hooks go in copyGeneric? |
ce57ce1
to
395b858
Compare
395b858
to
ae70f47
Compare
Yes. Much better, then it triggers on all the entities that are copied. |
@@ -98,6 +98,7 @@ public function preProcess() { | |||
$components = array('Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity'); | |||
|
|||
// FIXME: This should use a modified version of CRM_Contact_Form_Search::getModeValue but it doesn't have all the contexts | |||
// FIXME: Or better still, use CRM_Core_DAO_AllCoreTables::getBriefName($daoName) to get the $entityShortName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this is comment is unrelated to this PR... but I was looking for a function to get the Entity shortname and I found it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this and confirmed the call of post hook on Event copy as well as while creating a copy of a Contribution page.
Also tested an API call with $params['template_id']
and it copies the event correctly.
ok to merge.
@@ -920,13 +920,11 @@ public static function &getCompleteInfo( | |||
* @param int $id | |||
* The event id to copy. | |||
* boolean $afterCreate call to copy after the create function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also remove this line?
thanks @jitendrapurohit merged. @mattwire - one comment for possible follow up above^^ |
@mattwire is there any related ticket to close? |
Overview
When creating a copy of an event via API Event.create (with a template ID) (or directly using the CRM_Event_BAO_Event::copy function - as called from ManageEvents-"Copy" in the UI) a "copy" hook is called but the expected Event.create hook is not called, despite a new event being created.
In addition the copy function (which is only called in two places) has complexities to support passing in an already copied event. This seems unnecessarily complex and this PR simplifies that so it is always responsible for creating the copied event.
Note: Copying events via the "Repeat Events" (RecurringEntity) functionality doesn't use this function... It hardcodes it's own version which should be replaced with this copy function in a future PR.
Before
CRM_Event_BAO_Event::copy()
doesn't call the "create" hook when an event is created and adds unnecessary complexity by allowing an already created event to be passed in.After
CRM_Event_BAO_Event::copy()
calls the "create" (post) hook when an event is created and simplifies the function so it is easier to maintain and simpler.Technical Details
The "pre" hook is still not implemented because this would require conversion from an object to a params array and changes can be made via the "post" hook if required.
Comments
This change should be NFC. The API remains the same, if extensions are calling
CRM_Event_BAO_Event::copy()
directly (which is unsupported) they will need to switch to use the API. However I'm not aware of any extensions that do call that function.